<template>
  <div id="homeView">
    <ListMessCard :data-list="contentList" />
  </div>
</template>

<script setup lang="ts">
import ListMessCard from '@/components/ListMessCard.vue'
import { listContentVoByPageUsingPost } from '@/service/api/contentController'
import { message } from 'ant-design-vue'
import { onMounted, ref } from 'vue'

const searchParams = ref({
  current: 1,
  pageSize: 10,
})

const contentList = ref<API.ContentVO[]>([])

const loadData = async () => {
  const res = await listContentVoByPageUsingPost(searchParams.value)

  if (res.data.code === 0) {
    //tips 这里 res.data.data 可能是空值，所以直接访问 res.data.data.records 会报错
    contentList.value = res.data.data?.records || []
  } else {
    message.error(res.data.message || '数据获取失败')
  }
}

onMounted(() => {
  loadData()
})
</script>
